@extends('adminDialog')

@section('content')
    <form action="{{url('admin/product/newt/'.$model->categoryid)}}" method="POST" class="J_ajaxForm">
        <input type="hidden" name="_token" value="{{ csrf_token() }}">
        <div class="pop_cont pop_table" style="overflow-y: scroll;">
            <table width="100%">
                <tbody>
                <tr>
                    <th><label for="title">类别名称 <span class="red">*</span></label></th>
                    <td>
                        <input type="text" name="name" id="name" class="input length_6" value="{{$model->name}}"/>
                    </td>
                </tr>
                <tr>
                    <th><label for="">类别图片</label></th>
                    <td>
                        <a href="javascript:;" id="pic" class="pic" title="选择上传文件">
                            <input id="bigimgurl" type="hidden" name="bigimgurl" value="{{$model->bigimgurl}}"/>
                            <input id="smallimgurl" type="hidden" name="smallimgurl" value="{{$model->smallimgurl}}"/>
                            <img src="{{ $model->bigimgurl }}" onerror="this.src='{{url("images/14417770931301.png")}}'"/>
                        </a>
                    </td>
                </tr>
                <tr>
                    <th><label for="title">父级分类 <span class="red">*</span></label></th>
                    <td>
                        <select name="parentid">
                            @foreach($parents as $key=>$parent)
                                <option value="{{$key}}">{{$parent}}</option>
                            @endforeach
                        </select>
                    </td>
                </tr>
                <tr>
                    <th><label for="title">类别简介 <span class="red">*</span></label></th>
                    <td>
                        <textarea type="text" name="content" id="content" style="width: 600px;height: 200px;"> {{$model->content}} </textarea>
                    </td>
                </tr>
                <tr>
                    <th><label for="title">是否启用 <span class="red">*</span></label></th>
                    <td>
                        <input type="radio" name="isShow" value="1" {{1 == $model->status ? "checked='checked'" : ''}}/> 启用
                        <input type="radio" name="isShow" value="0" {{1 != $model->status ? "checked='checked'" : ''}}/> 停用
                    </td>
                </tr>

                </tbody>
            </table>
        </div>

        <div class="pop_bottom cc">
            <button type="reset" class="btn fr" id="J_dialog_close">取消</button>
            <button type="submit" class="btn btn_submit J_ajax_submit_btn fr mr10" id="J_dialog_close">提交</button>
        </div>
    </form>
@stop

@section('style')
    <style>
        .body_none {
            width: 720px;
        }
    </style>
@stop

@section('js')
    @parent
    @include('UEditor::head')
    <script src="{{ asset('js/plupload/plupload.full.min.js') }}"></script>
    <script src="{{asset("js/jsAddress.js")}}"></script>
    <script>
        $(function () {
            var uploader = new plupload.Uploader({
                runtimes: 'html5,flash,silverlight,html4',
                browse_button: 'pic', // you can pass in id...
                //container: document.getElementById('container'), // ... or DOM Element itself
                url: "{{ url('upimg') }}",
                filters: {
                    max_file_size: '5mb',
                    mime_types: [
                        {title: "Image files", extensions: "jpg,gif,png"}
                    ]
                },
                multi_selection: false,
                file_data_name: 'file',
                multipart_params: {'_token': '{{ csrf_token() }}', 'dir': 'marriage'},
                // Flash settings
                flash_swf_url: '{{ asset("js/plupload/Moxie.swf") }}',
                // Silverlight settings
                silverlight_xap_url: '{{ asset('js/plupload/Moxie.xap') }}',
                init: {
                    PostInit: function () {
                        return false;
                    },
                    FilesAdded: function (up, file) {
                        $('.up-pic img').attr('src', '{{ asset('images/loading.gif') }}');
                        uploader.start();
                    },
                    Error: function (up, err) {
                        tips(err.message);
                    },
                    FileUploaded: function (up, file, responseObj) {
                        var response = $.parseJSON(responseObj.response);
                        if (response.state == 'success') {
                            $('.pic img').attr('src', '{!! url("img/marriage-' + response.id + '/100-100") !!}');
                            $('.pic input').val( 'src','{!! url("img/marriage-' + response.id + '/100-100") !!}');
                            $('#smallimgurl').val('src', '{!! url("img/marriage-' + response.id + '/50-50") !!}');
                        } else {
                            tips(response.message);
                        }
                    }
                }
            });
            uploader.init();
        });
    </script>
@stop